package com.nbgroup.mapper;

import com.github.pagehelper.Page;
import com.nbgroup.pojo.Contract;
import com.nbgroup.pojo.dto.DeptListDto;
import com.nbgroup.pojo.dto.DeptListDto1;
import com.nbgroup.pojo.dto.PageCluesStatisticsDTO;
import com.nbgroup.pojo.dto.PageContractStatisticsDTO;
import com.nbgroup.pojo.vo.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface StatementMapper {
    List<ClientStatementMessagesVo> clientStatement(LocalDate begin, LocalDate end);

    List<SalesStatisticsMessageVo> salesStatistics(LocalDate begin, LocalDate end);

    List<ClueStatementMessagesVo> cluesStatistics(LocalDate begin, LocalDate end);

    CluePercentVo getVulnerabilityMap(LocalDate begin, LocalDate end);

    List<ChanelStatisticsVo> chanelStatistics(LocalDate begin, LocalDate end);

    List<ActivityStatisticsVo> activityStatistics(LocalDate begin, LocalDate end);

    List<SubjectStatisticsVo> subjectStatistics(LocalDate begin, LocalDate end);


    Page<CluesStatisticsVo> cluesStatisticsList(PageCluesStatisticsDTO pageDto);

    //往客户统计表插入数据
    Integer selectNewClient(LocalDate date, LocalDate date1);

    Integer selectTotalClient(LocalDate date1);

    void add(LocalDate date, Integer newClient, Integer totalClient);

    //查询销售额
    Double selectAmount(LocalDate date, LocalDate date1);

    @Insert("insert into  sales_statistics(date, amount)values( #{date}, #{amount})")
    void addSales(LocalDate date, Double amount);

    /**
     * 归属人
     *
     * @param begin
     * @param end
     * @return
     */
    List<OwnerShipVo> queryPeople(DeptListDto dto, LocalDate begin, LocalDate end);

    List<DeptVo> queryDeptList(DeptListDto dto, LocalDate begin, LocalDate end);

    List<ChanVo> queryChan(DeptListDto dto, LocalDate begin, LocalDate end);

    //cx新线索数量
    Integer selectNewClue(LocalDate date, LocalDate date1);

    //cx总线索数
    Integer selectTotalClue(LocalDate date1);

    //往线索统计表插数据
    void addClue(LocalDate date, Integer newClue, Integer totalClue);

    List<ActivityListvo> activityStatisticsList(String code, String name, Integer total);

    Page<ContractStatisticsListVO> pageQuery(PageContractStatisticsDTO pageDto);

    //查询线索池数量
    @Select("select count(*) from clue_record where create_time between #{date} and #{date1}")
    Integer selectCluesNums1(LocalDate date1);

    @Select("select count(*) from clue where create_time between #{date} and #{date1}")
    Integer selectCluesNums2( LocalDate date,LocalDate date1);

    //查询商机数
    Integer selectBusinessNums(LocalDate date,LocalDate date1);

    Integer selectContractNums(LocalDate date, LocalDate date1);

    void addPercent(LocalDate date,Integer cluesNums, Integer effectiveCluesNums, Integer businessNums, Integer contractNums);
}
